//
//  UIButton+YTAdd.h
//  Demo
//
//  Created by 拓客营 on 2022/3/28.
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, KBEdgeInsetsStyle) {
    KBEdgeInsetsStyleImageLeft,     // image在左，label在右 默认
    KBEdgeInsetsStyleImageRight,    // image在右，label在左
    KBEdgeInsetsStyleImageTop,      // image在上，label在下
    KBEdgeInsetsStyleImageBottom    // image在下，label在上
};


@interface UIButton (YTAdd)

// 扩大button点击范围
@property (nonatomic, assign) CGFloat expandMargin;

@property (nonatomic, assign) CGSize expandSize;

@property (nonatomic, assign) UIEdgeInsets expandEdgeInsets;

/**
 *  设置button的titleLabel和imageView的布局样式，及间距
 *
 *  @param style titleLabel和imageView的布局样式
 *  @param space titleLabel和imageView的间距
 */
- (void)setEdgeInsetsStyle:(KBEdgeInsetsStyle)style
           imageTitleSpace:(CGFloat)space;

- (void)buttonWithTitle:(NSString *)title titleColor:(UIColor *)titleCocor font:(UIFont *)font image:(UIImage *)image;

- (void)setLayerBorderWithBorderColor:(UIColor *)borderColor borderWidth:(float)borderWidth;

- (void)layerColor:(UIColor *)color cornerRadius:(float)cornerRadius;


/**
 *  设置button的背景渐变色 和圆角的布局样式 横向
 *
 *  @param leftColor 起点位置的颜色
 *  @param rightColor 终点位置的颜色
 *  @param cornerRadius button的圆角设置
 *  @param size button的大小
 */
- (void)layerFromColor:(UIColor *)leftColor toColor:(UIColor *)rightColor cornerRadius:(float)cornerRadius size:(CGSize)size;

- (void)layerFromColor:(UIColor *)leftColor toColor:(UIColor *)rightColor startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint cornerRadius:(float)cornerRadius size:(CGSize)size;

// 纵向
- (void)layerDownFromColor:(UIColor *)leftColor toColor:(UIColor *)rightColor cornerRadius:(float)cornerRadius size:(CGSize)size;

// 自定义渐变
-(void)customGradientWithCornerRadius:(float)cornerRadius size:(CGSize)size;

- (void)backgroundColor:(UIColor *)backgroundColor cornerRadius:(float)cornerRadius;

+ (void)setPathToRoundedRect:(CGRect)rect forInset:(NSUInteger)inset inContext:(CGContextRef)context;


/**
 *  设置button的背景渐变色 和圆角的布局样式
 *
 *  @param title 标题
 *  @param color 字体颜色
 *  @param bgColor 背景图片
 *  @param fontSize 字体大小
 */
+(UIButton *)buttonConfig:(NSString *)title titleColor:(UIColor *)color backgroundColor:(UIColor *)bgColor fontSize:(CGFloat)fontSize;

@end

NS_ASSUME_NONNULL_END
